n=7
%m=22
niteraciones = 1200;

for m=10:23
    m
    maximo = power(m,n)
    maximocomb = factorial(m)/(factorial(n)*factorial(m-n))
    
    if (maximo<maximocomb)
        seq = zeros(1,maximo);
    else
        seq = zeros(1,maximocomb);
    end
        iteracion = 1;

    while (iteracion <= maximocomb && iteracion <= niteraciones)
        v = ceil(m.*rand(1,n))-1;
        for i=2:n
            while (find(v(i) == v(1:i-1)))
                v(i) = mod(v(i)+1, m);
            end
        end

        num_base_m =char([v(find(v<10))+'0' v(find(v>=10))+'A'-10]);
        num_base_m = sort(num_base_m);
        num = base2dec(num_base_m, m);

        if (find(num == seq(1:iteracion-1)))
        else
            seq(iteracion) = num;
            iteracion = iteracion+1;
        end
    end

    if (~all(diff(sort(seq))))
        error('all(diff(sort(seq)))')
        return
    end

    seq_base_m = dec2base(seq, m);
    eval(sprintf('seq_base_%d = seq_base_m;', m));
    eval(sprintf('sort(seq_base_%d)',m))
end